package com.cangsan.erhai.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cangsan.erhai.entity.SysMenu;
import com.cangsan.erhai.mapper.SysMenuMapper;
import com.cangsan.erhai.service.SysMenuService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 76118
* @description 针对表【sys_menu(菜单权限表)】的数据库操作Service实现
* @createDate 2024-09-17 08:19:13
*/
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu>
    implements SysMenuService{

    @Override
    public List<SysMenu> buildreeMen(List<SysMenu> sysMenuList) {
        List<SysMenu> resultList = new ArrayList<>();

        for (SysMenu sysMenu : sysMenuList) {

            for (SysMenu e : sysMenuList) {

                if(e.getParentId().equals(sysMenu.getMenuId())){
                    sysMenu.getChildren().add(e);
                }
            }

            if(sysMenu.getParentId()==0L){
                resultList.add(sysMenu);
            }
        }

        return resultList;
    }
}




